package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.BaseCodeTypeService;
import com.yixun.qfbao.apidto.EditBaseCodeTypeReqDto;
import com.yixun.qfbao.apidto.EditBaseCodeTypeResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.EditBaseCodeTypeReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 标签修改
 * @author guifang.weng
 * @create 2017-11-24 10:07
 **/
@Service
public class EditBaseCodeTypeHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(EditBaseCodeTypeHander.class);

    @Autowired
    private BaseCodeTypeService baseCodeTypeService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<EditBaseCodeTypeResDto> res = new BaseResponseDTO<>();
        EditBaseCodeTypeReqVo reqVo = (EditBaseCodeTypeReqVo)reqDto;
        EditBaseCodeTypeReqDto editBaseCodeTypeReqDto = reqVo.getParams();
        try {
            EditBaseCodeTypeResDto resDto = baseCodeTypeService.editBaseCodeType(editBaseCodeTypeReqDto);
            res.setResult(resDto.getResult());
            res.setResData(resDto);
        } catch (Exception e) {
            logger.error("EditBaseCodeTypeHander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("修改标签失败");
        }
        return res;
    }
}
